home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
dev
/
obero
/
oberon_lib.lha
/
oberon-a
/
source1.lha
/
source
/
AmigaUtil
/
DosUtil.mod
< prev
next >
Wrap
Text File
|
1994-08-08
|
2KB
|
76 lines
(***************************************************************************
$RCSfile: DosUtil.mod $
Description: Support for clients of dos.library
Created by: fjc (Frank Copeland)
$Revision: 3.2 $
$Author: fjc $
$Date: 1994/08/08 16:09:42 $
Copyright © 1994, Frank Copeland.
This file is part of the Oberon-A Library.
See Oberon-A.doc for conditions of use and distribution.
***************************************************************************)
MODULE DosUtil;
(*
** $C- CaseChk $I= IndexChk $L+ LongAdr $N- NilChk
** $P- PortableCode $R- RangeChk $S- StackChk $T- TypeChk
** $V- OvflChk $Z- ZeroVars
*)
IMPORT Exec, Dos, Str := Strings;
(*------------------------------------*)
PROCEDURE FileExists * (path : ARRAY OF CHAR) : BOOLEAN;
VAR lock : Dos.FileLockPtr; result : BOOLEAN;
(* $D- disable copying of open arrays *)
BEGIN (* FileExists *)
result := FALSE;
lock := Dos.base.Lock (path, Dos.sharedLock);
IF lock # NIL THEN result := TRUE; Dos.base.UnLock (lock) END;
RETURN result
END FileExists;
(*------------------------------------*)
(*
Searches for "file" in the current directory first, followed by the
directories listed in "paths". If it is found the procedure returns TRUE
and the full pathname of the file is returned in "fullPath". If not, the
procedure returns FALSE and fullPath is set to "".
*)
PROCEDURE Search *
( VAR paths : ARRAY OF Exec.STRPTR;
file : ARRAY OF CHAR;
VAR fullPath : ARRAY OF CHAR)
: BOOLEAN;
VAR index : INTEGER; len : LONGINT; ch : CHAR;
(* $D- disable copying of open arrays *)
BEGIN (* Search *)
fullPath [0] := 0X; index := 0;
LOOP
Str.Append (fullPath, file);
IF FileExists (fullPath) THEN RETURN TRUE END;
IF paths [index] = NIL THEN
fullPath [0] := 0X; RETURN FALSE
ELSE
COPY (paths [index]^, fullPath); INC (index);
len := Str.Length (fullPath);
IF len > 0 THEN
ch := fullPath [len - 1];
IF (ch # ":") & (ch # "/") THEN Str.Append (fullPath, "/") END
END
END
END
END Search;
END DosUtil.